/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.gatech.gellinservlet.model;

import java.io.IOException;
import java.util.logging.*;

/**
 * Singleton design pattern
 * @author Tyler Powell
 */
public class Log
{
    private volatile static Logger ourLogger; 
    
    //prevent instantiation of singleton Log class
    private Log(){}
    
    //public getter method for logger
    public static Logger getInstance(){
        if(ourLogger == null){
            synchronized (Log.class){
                if(ourLogger == null){
                    ourLogger = Logger.getLogger("edu.gatech.gellinservlet.model.Log");
                }
            }
        }
        return ourLogger;
    }

    static {
        FileHandler fh = null;
        try {
            fh = new FileHandler("ourLogger.log");
        } catch (SecurityException e) {
            ourLogger.log(Level.SEVERE, "Security Exception creating the logger file handler", e);
            e.printStackTrace();
        } catch (IOException e) {
            ourLogger.log(Level.SEVERE, "IO Exception creating the logger file handler", e);
            e.printStackTrace();
        }

        fh.setFilter(new Filter() {

            public boolean isLoggable(LogRecord record) {
                return true;
            }
        });
        ourLogger.addHandler(fh);
        ourLogger.setLevel(Level.ALL);
    }
    
}
